<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">

    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css"/>

</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 软件审核管理 <span
        class="c-gray en">&gt;</span>申请列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                             href="javascript:location.replace(location.href);" title="刷新"
                                             id="refresh"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>

<div class="page-container">
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="80">ID</th>
                <th width="300">上传人</th>
                <th width="100">名称</th>
                <th width="100">大小</th>
                <th width="150">上传时间</th>
                <th width="100">下载量</th>
                <th width="80">状态</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="data" items="${dataMap}">
                <tr class="text-c">
                    <td>${data[0]}</td>
                    <td><a href="#"
                           onclick="lookInfo('开发者详情','/accountAdmin/admin/accountInfo?id=${data[4]}')">${data[4]}</a>
                    </td>
                    <td>
                        <a href="#"
                           onclick="lookInfo('软件详情','/SoftwareAdmin/admin/softInfo?id=${data[0]}')">${data[1]}</a>
                    </td>
                    <td>${data[2]}</td>
                    <td><fmt:formatDate value="${data[3]}" pattern="yyyy-MM-dd HH:mm"/></td>

                    <td><c:if test="${data[5]==null}">0</c:if>
                        <c:if test="${data[5]!=null}">${data[5]}</c:if></td>

                    <td class="status"><c:choose>
                        <c:when test="${data[6]==0}">审核中</c:when>
                        <c:when test="${data[6]==1}"><span style="color: green;">上线中</span></c:when>
                        <c:when test="${data[6]==2}">下线申请中</c:when>
                        <c:when test="${data[6]==-1}">审核未通过</c:when>
                        <c:when test="${data[6]==-2}"><span style="color:red;">下线中</span></c:when>
                        <c:when test="${data[6]==-3}">下线未通过</c:when>


                    </c:choose></td>
                    <td><a title="查看评论"
                           onclick="lookInfo('软件评论','/SoftwareAdmin/admin/lookSpeakingInfo?id=${data[0]}')"
                           class="ml-5" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe622;</i></a>
                        <a title="下载" href="/massageExamineAction/admin/downloadApk?md5=${data[8]}"
                           class="ml-5" style="text-decoration:none">
                            <i class="Hui-iconfont">&#xe640;</i></a>

                        <c:choose>

                            <c:when test="${data[6]==1}"><a title="下线"
                                                            data-value="${data[0]}"
                                                            data-status="-2"
                                <%--onclick="admin_state(this,${data[0]},-2)"--%>
                                                            class="ml-5 online"
                                                            style="text-decoration:none"><i
                                    class="Hui-iconfont">&#xe6de;</i></a></c:when>
                            <c:when test="${data[6]==-2}"><a title="上线"
                                                             data-value="${data[0]}"
                                                             data-status="1"

                                                             class="ml-5 online"
                                                             style="text-decoration:none"><i
                                    class="Hui-iconfont">&#xe603;</i></a></c:when>


                        </c:choose>


                        <a title="删除"
                           onclick="admin_state(this,${data[0]},0)"
                           class="ml-5"
                           style="text-decoration:none"><i
                                class="Hui-iconfont">&#xe6e2;</i></a>


                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
<!--[if lt IE 9]>
<script type="text/javascript" src="/admin/lib/html5shiv.js"></script>
<script type="text/javascript" src="/admin/lib/respond.min.js"></script>
<![endif]-->
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
<script>


    $(function () {
        $('.table-sort').dataTable({
            "aaSorting": [[6, "desc"]],//默认第几个排序
            // "bStateSave": true,//状态保存
            // "aoColumnDefs": []
        });

    });

    /*添加-版本*/
    function lookInfo(title, url) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }

    $(document).ready(function () {
        $('.online').click(function () {
            admin_state($(this), $(this).attr('data-value'), $(this).attr('data-status'));
        });
    });


    function admin_state(obj, id, state) {
        layer.confirm('你确认要执行该操作?', function (index) {
            $.ajax({
                type: 'POST',
                url: '/SoftwareAdmin/admin/adminSoftwareState',
                data: {"id": id, "state": state},
                dataType: 'json',
                success: function (data) {
                    if (data.code == 200) {
                        if (state == 0) {
                            $(obj).parents("tr").remove();
                        }
                        else if (state == 1) {
                            //修改为绿色 并修改 下线图标
                            $(obj).parent().prev().css("color", 'green').text('上线中');
                            $(obj).attr('title', '下线');
                            //&#xe603;
                            $(obj).html('<i class="Hui-iconfont">&#xe6de;</i>').attr('data-status', '-2');
                        } else if (state == -2) {
                            //修改为红色，并修改为上线图标 &#xe6de;
                            $(obj).parent().prev().css("color", 'red').text('下线中');
                            $(obj).attr('title', '上线');
                            //&#xe603;
                            $(obj).html('<i class="Hui-iconfont">&#xe603;</i>').attr('data-status', '1');

                        }
                        layer.msg('操作成功,刷新查看', {icon: 1, time: 1000});
                    } else {
                        layer.msg('操作失败!', {icon: 1, time: 1000});
                    }

                },
                error: function (data) {
                },
            });
        });
    }

</script>
</body>
</html>